package io.github.junxworks.qt.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

import io.github.junxworks.qt.modules.strategy.ws.BacktestWebSocketHandler;
import io.github.junxworks.qt.modules.strategy.ws.DebugWebSocketHandler;

@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {

	@Autowired
	private DebugWebSocketHandler debugWebSocketHandler;

	@Autowired
	private BacktestWebSocketHandler backtestWebSocketHandler;

	@Override
	public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
		registry.addHandler(debugWebSocketHandler, "ws/strategy/debug/**").setAllowedOrigins("*");
		registry.addHandler(backtestWebSocketHandler, "ws/strategy/backtest/**").setAllowedOrigins("*");
	}
}